$(function(){
    $("#form-member-add").validate({
        rules:{
            topic:{
                required:true
            },
            /* activityUrl:{
                 required:true
             },*/
            name:{
                required:true
            },
            start:{
                required:true
            },
            end:{
                required:true
            },
        },
        onkeyup:false,
        focusCleanup:true,
        success:"valid",
        submitHandler:function(form){
           /* var discountsPrice=$("#discountsPrice").val();
            $("#discountsPrice").val(discountsPrice*100);*/
            $("#form-member-add").ajaxSubmit({
                cache:true,
                type:'POST',
                dataType: 'json',
                data:$('#form-member-add').serialize(),
                url:'/admin/distributionRate/modifiyDistributionRate.html',
                async: false,
                success:function(data){
                    console.log(data);
                    if (data.code != 1){
                        layer.msg(data.msg,{icon : 5,time : 1000});
                        console.log(data.msg);
                        return;
                    }
                    layer.msg('操作成功!',{icon : 6,time : 1000},function(){
                        window.parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    })
                }
            })
        }
    });
});

function delDistributionRateById(tid){
    layer.confirm('确认删除吗？',function(index){
        // var postData = {"activityId": activityId,"activityName": activityName,"activityUrl": activityUrl};
        $.ajax({
            cache:true,
            type:'POST',
            url:'/admin/distributionRate/delDistributionRateById.html?tid='+tid,
            dataType: 'json',
            async: false,
            success:function(data){
                console.log(data);
                // alert(data.code);
                if (data.code != 1){
                    layer.msg('操作失败!',{icon : 5,time : 1000});
                    console.log(data.msg);
                    return;
                }
                layer.msg('操作成功!',{icon : 6,time : 1000},function(){
                    location.reload();
                    // var index = parent.layer.getFrameIndex(window.name);
                    // parent.layer.close(index);
                })
            }
        })
    });
}